package com.odt.outdoor.widget;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.odt.outdoor.R;
import com.odt.outdoor.utils.DensityUtil;


/**
 * Created by DELL on 2017/2/9.
 */

public class TableView extends LinearLayout {
    private int ivSelect;
    private int ivNormal;
    private Context mContext;
    private ImageView imageView;
    private TextView textView;

    public TableView(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
        init(context);
    }

    public TableView(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
        init(context);
        ivSelect = attrs.getAttributeResourceValue("http://schemas.android.com/apk/res-auto", "tabSelectImg", R.drawable.ic_launcher);
        ivNormal = attrs.getAttributeResourceValue("http://schemas.android.com/apk/res-auto", "tabNormalImg", R.drawable.ic_launcher);
        textView.setText(attrs.getAttributeValue("http://schemas.android.com/apk/res-auto", "tabName"));
        textView.setTextColor(attrs.getAttributeIntValue("http://schemas.android.com/apk/res-auto","tabColor",R.color.white));
        textView.setTextSize(attrs.getAttributeIntValue("http://schemas.android.com/apk/res-auto","tabTextSize", DensityUtil.dip2px(mContext,12)));
        imageView.setImageResource(ivNormal);
    }

    private void init(Context context){
        mContext = context;
        View.inflate(mContext, R.layout.rl_tabhost_layout, this);
        imageView = (ImageView) findViewById(R.id.iv_tabhost);
        textView = (TextView) findViewById(R.id.tv_tabhost);
    }
    public void select(){
        imageView.setImageResource(ivSelect);
        textView.setTextColor(ContextCompat.getColor(mContext,R.color.blue));

    }

    public void cancle(){

        imageView.setImageResource(ivNormal);
        textView.setTextColor(ContextCompat.getColor(mContext,R.color.widgets_general_row_normal));
    }


}


